<?php

$this->addTitle($lang['overview']['fleet_title']);
echo "<h3>".$lang['overview']['fleet_title']."</h3><br />";
echo "\n";
echo '<div align="center" style="padding-bottom:10px;"><span style="font-size:80%;">';
	if(isset($_GET['ally'])) {
		$p_ally=$_GET['ally'];
		unset($_GET['ally']);
	}else
		$p_ally="";
	
	echo "<a href=\"".FullURL()."&ally=".$this->user_ally_id."\">".$this->user_ally_tag."</a> ";
	
	echo "<a href=\"".FullURL()."\">ALL</a> ";
	$_GET['ally']=$p_ally;
echo '</span></div>';

$sql_reduce="";
if(in_array($this->user_group, $restrict_ally_group) or in_array($this->user_id, $restrict_ally_user))
	$sql_reduce="\n\tAND\n\tal.ally_id=".$this->user_ally_id;
if(in_array($this->user_group, $restrict_user_group) or in_array($this->user_id, $restrict_user_user))
	$sql_reduce="\n\tAND\n\tus.user_id=".$this->user_id;


include(getcwd()."/plugin/class/class_list.php");
if(is_numeric($p_ally))
	$lines="WHERE al.ally_id =".$p_ally." $sql_reduce";
else
	$lines="WHERE 1=1 $sql_reduce";

$this->sql->queryS("SET @counter:=0;");

$addsql="fl LEFT JOIN ".$this->sql->getpre()."users us ON us.user_id=fl.user_id LEFT JOIN ".$this->sql->getpre()."ally al ON al.ally_id=us.user_ally";
$frow=array(
	"<>"=>"(@counter:=@counter+1) AS `<>`",
	"Spieler"=>"user_name",
	"KT"=>"IF((SELECT MAX(fleet_kt) FROM ".$this->sql->getpre()."fleet $addsql $lines)=fleet_kt, CONCAT('<span style=\"color:red; font-weight:bold;\">',fleet_kt,'</span>'), fleet_kt) AS KT",
	"GT"=>"IF((SELECT MAX(fleet_gt) FROM ".$this->sql->getpre()."fleet $addsql $lines)=fleet_gt, CONCAT('<span style=\"color:red; font-weight:bold;\">',fleet_gt,'</span>'), fleet_gt) AS GT",
	"LJ"=>"IF((SELECT MAX(fleet_lj) FROM ".$this->sql->getpre()."fleet $addsql $lines)=fleet_lj, CONCAT('<span style=\"color:red; font-weight:bold;\">',fleet_lj,'</span>'), fleet_lj) AS LJ",
	"SJ"=>"IF((SELECT MAX(fleet_sj) FROM ".$this->sql->getpre()."fleet $addsql $lines)=fleet_sj, CONCAT('<span style=\"color:red; font-weight:bold;\">',fleet_sj,'</span>'), fleet_sj) AS SJ",
	"Xer"=>"IF((SELECT MAX(fleet_xer) FROM ".$this->sql->getpre()."fleet $addsql $lines)=fleet_xer, CONCAT('<span style=\"color:red; font-weight:bold;\">',fleet_xer,'</span>'), fleet_xer) AS Xer",
	"SS"=>"IF((SELECT MAX(fleet_ss) FROM ".$this->sql->getpre()."fleet $addsql $lines)=fleet_ss, CONCAT('<span style=\"color:red; font-weight:bold;\">',fleet_ss,'</span>'), fleet_ss) AS SS",
	"SXer"=>"IF((SELECT MAX(fleet_sk) FROM ".$this->sql->getpre()."fleet $addsql $lines)=fleet_sk, CONCAT('<span style=\"color:red; font-weight:bold;\">',fleet_sk,'</span>'), fleet_sk) AS SXer",
	"KS"=>"IF((SELECT MAX(fleet_ks) FROM ".$this->sql->getpre()."fleet $addsql $lines)=fleet_ks, CONCAT('<span style=\"color:red; font-weight:bold;\">',fleet_ks,'</span>'), fleet_ks) AS KS",
	"Recy"=>"IF((SELECT MAX(fleet_recy) FROM ".$this->sql->getpre()."fleet $addsql $lines)=fleet_recy, CONCAT('<span style=\"color:red; font-weight:bold;\">',fleet_recy,'</span>'), fleet_recy) AS Recy",
	"Spio"=>"IF((SELECT MAX(fleet_spio) FROM ".$this->sql->getpre()."fleet $addsql $lines)=fleet_spio, CONCAT('<span style=\"color:red; font-weight:bold;\">',fleet_spio,'</span>'), fleet_spio) AS Spio",
	"Bomb"=>"IF((SELECT MAX(fleet_bomb) FROM ".$this->sql->getpre()."fleet $addsql $lines)=fleet_bomb, CONCAT('<span style=\"color:red; font-weight:bold;\">',fleet_bomb,'</span>'), fleet_bomb) AS Bomb",
	"Zer"=>"IF((SELECT MAX(fleet_zer) FROM ".$this->sql->getpre()."fleet $addsql $lines)=fleet_zer, CONCAT('<span style=\"color:red; font-weight:bold;\">',fleet_zer,'</span>'), fleet_zer) AS Zer",
	"Rip"=>"IF((SELECT MAX(fleet_tod) FROM ".$this->sql->getpre()."fleet $addsql $lines)=fleet_tod, CONCAT('<span style=\"color:red; font-weight:bold;\">',fleet_tod,'</span>'), fleet_tod) AS Rip",
	"AW"=>"IF((SELECT MAX((fleet_lj*50+fleet_sj*150+fleet_xer*400+fleet_sk*700+fleet_ss*1000+fleet_bomb*1000+fleet_zer*2000+fleet_tod*200000)*(forschung_waffentechnik/10+1)) FROM ".$this->sql->getpre()."fleet $addsql $lines)=(fleet_lj*50+fleet_sj*150+fleet_xer*400+fleet_sk*700+fleet_ss*1000+fleet_bomb*1000+fleet_zer*2000+fleet_tod*200000)*(forschung_waffentechnik/10+1), CONCAT('<span style=\"color:red; font-weight:bold;\">',FORMAT((fleet_lj*50+fleet_sj*150+fleet_xer*400+fleet_sk*700+fleet_ss*1000+fleet_bomb*1000+fleet_zer*2000+fleet_tod*200000)*(forschung_waffentechnik/10+1),0),'</span>'), FORMAT((fleet_lj*50+fleet_sj*150+fleet_xer*400+fleet_sk*700+fleet_ss*1000+fleet_bomb*1000+fleet_zer*2000+fleet_tod*200000)*(forschung_waffentechnik/10+1),0)) AS AW"
);
$srow=array(
);
$links=array(
);
$jump=array(
);
$adsq="GROUP BY us.user_id";


if(!isset($_GET['sort']))
	$_GET['sort']="user_name";

$planets=new LIST_UPAF($this, $this->sql,$frow,$srow, $links, $jump, $lines, $adsq, true);

$planets->generateList();


?>
